#region File Description
//-----------------------------------------------------------------------------
// MainMenuScreen.cs
//
// Microsoft XNA Community Game Platform
// Copyright (C) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
#endregion

#region Using Statements
using System;
#endregion

namespace POB
{
	/// <summary>
	/// The main menu screen is the first thing displayed when the game starts up.
	/// </summary>
	/// <remarks>
	/// This class is somewhat similar to one of the same name in the 
	/// GameStateManagement sample.
	/// </remarks>
	class MainMenuScreen : MenuScreen
	{
		#region Initialization


		/// <summary>
		/// Constructor fills in the menu contents.
		/// </summary>
		public MainMenuScreen()
		{
			MenuEntry playGameMenuEntry = new MenuEntry("Play Game");
			MenuEntry optionsMenuEntry = new MenuEntry("Options");
			MenuEntry exitMenuEntry = new MenuEntry("Exit");

			playGameMenuEntry.Selected += PlayGameMenuEntrySelected;
			optionsMenuEntry.Selected += OptionsMenuEntrySelected;
			exitMenuEntry.Selected += ExitMenuEntrySelected;

			MenuEntries.Add(playGameMenuEntry);
			MenuEntries.Add(optionsMenuEntry);
			MenuEntries.Add(exitMenuEntry);
		}


		#endregion

		#region Handle Input


		/// <summary>
		/// Event handler for when the Play Game menu entry is selected.
		/// </summary>
		void PlayGameMenuEntrySelected(object sender, EventArgs e)
		{
			LoadingScreen.Load(ScreenManager, LoadGameplayScreen, true);
		}


		/// <summary>
		/// Loading screen callback for activating the gameplay screen.
		/// </summary>
		void LoadGameplayScreen(object sender, EventArgs e)
		{
			World gameplayScreen = new World(System.Xml.Linq.XElement.Load(@"Gameplay\Unit1.xml"));
			ScreenManager.AddScreen(gameplayScreen);
		}


		/// <summary>
		/// Event handler for when the Options menu entry is selected.
		/// </summary>
		void OptionsMenuEntrySelected(object sender, EventArgs e)
		{
			//ScreenManager.AddScreen(new OptionsMenuScreen());
		}


		/// <summary>
		/// Event handler for when the Exit menu entry is selected.
		/// </summary>
		void ExitMenuEntrySelected(object sender, EventArgs e)
		{
			OnCancel();
		}


		/// <summary>
		/// When the user cancels the main menu, ask if they want to exit the sample.
		/// </summary>
		protected override void OnCancel()
		{
			const string message = "Exit Project Outbreak?";

			MessageBoxScreen messageBox = new MessageBoxScreen(message);
			messageBox.Accepted += ExitMessageBoxAccepted;
			ScreenManager.AddScreen(messageBox);
		}


		/// <summary>
		/// Event handler for when the user selects ok on the "are you sure
		/// you want to exit" message box.
		/// </summary>
		void ExitMessageBoxAccepted(object sender, EventArgs e)
		{
			ScreenManager.Game.Exit();
		}


		#endregion
	}
}
